package fhp.hlhj.giantfold.adapter

import android.content.Context
import android.support.v4.view.PagerAdapter
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.bumptech.glide.Glide
import fhp.hlhj.giantfold.R
import fhp.hlhj.giantfold.utils.LogUtil
import kotlinx.android.synthetic.main.annual_pager_item.view.*

/**
 * author: FHP
 * data: on 2017\11\30 0030 14:37
 * E-Mail: 103945089@qq.com
 */
class LevelAnnualViewPagerAdp(private val context: Context) :PagerAdapter() {

    override fun instantiateItem(container: ViewGroup, position: Int): Any {
        val rootView = LayoutInflater.from(context).inflate(R.layout.annual_pager_item,null)

        when(position){
            0 ->{
                rootView.img.setImageResource(R.mipmap.img_hy)
                rootView.itemTitle.text = "好友邀请"
                rootView.itemInfo.text="您的好友邀请数量，遨游使用频次和消费情况"
            }
            1->{
                rootView.img.setImageResource(R.mipmap.img_gw)
                rootView.itemTitle.text = "购物行为"
                rootView.itemInfo.text="购物行为是您购物过程中体现的行为特点，过多的退款会影响得分"
            }
            2->{
                rootView.img.setImageResource(R.mipmap.img_yq)
                rootView.itemTitle.text = "使用频率"
                rootView.itemInfo.text="使用软件的频率及购物的频率"
            }
            3->{
                rootView.img.setImageResource(R.mipmap.img_fx)
                rootView.itemTitle.text = "分享频率"
                rootView.itemInfo.text="您分享软件、商品的频率，分享效果也会统计"
            }
            4->{
                rootView.img.setImageResource(R.mipmap.img_xf)
                rootView.itemTitle.text = "消费能力"
                rootView.itemInfo.text="您的消费品类、金额，决定您的消费力"
            }
        }
        container.addView(rootView)
        return rootView

    }

    override fun destroyItem(container: ViewGroup, position: Int, `object`: Any?) {
//        super.destroyItem(container, position, `object`)
        container.removeView(`object` as View)
    }
    override fun isViewFromObject(view: View?, `object`: Any?): Boolean = view==`object`

    override fun getCount(): Int = 5
}